package com.zprmb.udzt;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.zprmb.udzt.gesture.GestureEditActivity;
import com.zprmb.udzt.gesture.GestureVerifyActivity;
import com.zprmb.udzt.ll.BaseHelper;
/**
 * 密码管理
 * @author shenshao
 *
 */
public class Password_Manger extends BaseActivity implements OnClickListener{
	private RelativeLayout rl_jy_pw,rl_login_pw,rl_gesture_pw;
	private TextView tv_gesture,tv_tr_pwd;
	private RelativeLayout rl_back;
	private ImageView img_back;
	private TextView tv_customer;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.password_manger);
		 BbtApplication.getInstance().addActvity(this);
		tv_tr_pwd=(TextView)findViewById(R.id.jy_pwd);
		rl_jy_pw=(RelativeLayout)findViewById(R.id.rl_jy_pw);
		rl_login_pw=(RelativeLayout)findViewById(R.id.rl_login_pw);
		rl_gesture_pw=(RelativeLayout)findViewById(R.id.rl_gesture_pw);
		img_back=(ImageView)findViewById(R.id.img_back);
		rl_back=(RelativeLayout)findViewById(R.id.rl_back);
		tv_customer=(TextView)findViewById(R.id.enterprise_tel);
		tv_customer.setOnClickListener(this);
		rl_back.setOnClickListener(this);
		img_back.setOnClickListener(this);
		rl_jy_pw.setOnClickListener(this);
		rl_login_pw.setOnClickListener(this);
		rl_gesture_pw.setOnClickListener(this);
		tv_gesture=(TextView)findViewById(R.id.tv_gesture_manger);
		if(getIntent().getBooleanExtra("pay", false)){
			tv_tr_pwd.setText("重置交易密码");
		}else{
			tv_tr_pwd.setText("设置交易密码");
		}
		
		ifFirst();
		}
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		BbtApplication.getInstance().removeActvity(this);
	}
	private void ifFirst(){
	
		if(getShare().getString(getMobile(), "").equals("")){
			tv_gesture.setText("设置手势密码");
			
			
		}else{
			tv_gesture.setText("修改手势密码");
		}
	} 
	@Override
	protected void onActivityResult(int arg0, int arg1, Intent arg2) {
		// TODO Auto-generated method stub
		ifFirst();
		Log.e("ss", "sss");
		super.onActivityResult(arg0, arg1, arg2);
	
		
	} 
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch(v.getId()){
		case R.id.rl_jy_pw:
			if(tv_tr_pwd.getText().toString().equals("设置交易密码")){
				Intent intent=new Intent(Password_Manger.this,Set_tr_pw.class);
				startActivity(intent);
				
			}else{
				Intent intent=new Intent(Password_Manger.this,Reset_pwd_Mes.class);
				startActivity(intent);
			}
			break;
		case R.id.rl_login_pw:
			Intent intent2=new Intent(Password_Manger.this,Update_login_pw.class);
			startActivity(intent2);
			break;
		case R.id.rl_gesture_pw:
			if(getShare().getString(getMobile(), "").equals("")){
				Intent intent3=new Intent(Password_Manger.this,GestureEditActivity.class);	
				intent3.putExtra("update", 1);
				startActivityForResult(intent3, 1);
			}else{
				Intent intent3=new Intent(Password_Manger.this,GestureVerifyActivity.class);	
				intent3.putExtra("update", 1);
				startActivityForResult(intent3, 1);
				
			}
			break;
		case R.id.img_back:
			finish();
			break;
		case R.id.rl_back:
			finish();
			break;
		case R.id.enterprise_tel:
			BaseHelper.showDialog2(this, "拨号", "400-0101-016", 1);
			break;
		}
	}

}
